﻿@using Models;
@model MvcPager.Page<user_question_answer>
@{
    ViewBag.Title = "调研列表";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<div class="container">
    <div class="breadcrumb">
        <ul>
            <li>
                <a href="/admin/Account/Index">
                    <span class="fa fa-home"></span>
                    <span>返回主菜单&nbsp;&gt;&nbsp;</span>
                </a>
            </li>
            <li>
                <a href="javascript:void(0);">
                    <span class="active-b">调研管理</span>
                </a>
            </li>
        </ul>
    </div>
</div>
<div class="container">
    <form class="form-inline" action="" autocomplete="off" onkeydown="if(event.keyCode==13)return false;">
        <div class="form-group">
            <label>昵称</label>
            <input class="width-210" type="text" name="NickName" placeholder="请输入昵称">
        </div>
        <div class="form-group">
            <label>调研题目</label>
            <input class="width-210" type="text" name="Title" placeholder="请输入调研题目">
        </div>
        <div class="form-group">
            <a class="btn-search" href="javascript:void(0);" onclick="skipPage()">
                <i class="fa fa-search"></i>
            </a>
        </div>
        <div class="form-group pull-right">
            <a class="btn btn-primary" href="/admin/survey/export">
                <i class="fa fa-download"></i>
                导出
            </a>
        </div>
        <div class="form-group pull-right">
            <a class="btn btn-primary" href="javascript:void(0);" onclick="ClearData(this)" data-url="/admin/survey/cleardata">
                <i class="fa fa-trash"></i>清除调研数据
            </a>
        </div>
    </form>

    <div id="ui-pager">
        @Html.Partial("_Index", Model)
    </div>
</div>
<script>
    var ajaxLock = false;
    function ClearData(target) {
        if (ajaxLock) {
            return false;
        } else {
            ajaxLock = true;
            var confirmid = elayer.confirm('删除', '清除后<span style="color:red;">不可恢复</span>，你确认要清除调研数据吗？', function () {
                $.ajax({
                    url: $(target).data('url'),
                    type: 'post',
                    error: function (e) {
                        alert(e.responseText);
                        elayer.alert('错误', '网络连接失败...');
                        elayer.close(confirmid);
                    },
                    success: function (data) {
                        elayer.close(confirmid);
                        if (!data.status) {
                            elayer.alert('错误', data.errmsg);
                        }
                        else if (data.status) {
                            skipPage();
                            elayer.alert('错误', data.data);
                        }
                    },
                    complete: function (XMLHttpRequest, textStatus) {
                        ajaxLock = false;
                    },
                });
            });
        }
    }
</script>
